package com.unytech.project.entity.mail;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.unytech.project.entity.BaseEntity;

/**
 * 邮件类
 * @author DolphinBoy
 *
 */
@Entity 
@Table(name="T_MAIL")
@GenericGenerator(name="uuidpk",strategy="uuid")
public class Mail extends BaseEntity {
	@Id @GeneratedValue(generator="uuidpk")
	@Column(length=32)
	private String mailid;
	
	/** 邮件主题 */
	@Column(length=50)
	private String subjec;
	
	/** 邮件内容 */
	@Lob
	@Basic(fetch=FetchType.LAZY) 
//	@Column(columnDefinition="LOGNTEXT") 
	private String content;
	
	/** 发件人 */
	@Column(name="mailfrom")
	private String from;
	
	/** 接收人 */
	@Column(length=50)
	private String sendto;
	
	/** 抄送人 */
	@Column(length=50)
	private String cperson;
	
	/** 按送人 */
	@Column(length=50)
	private String bcperson;
	
	/** 是否是超文本内容电子邮件 */
	private Integer mimemessage = 0;
	
	/** 是否发送成功 */
	private Integer sentok = 1;
	
	/** 如果出错，记录出错信息 */
	private String errormessage;
	
	/** 发送日期 */
	@Temporal(TemporalType.TIMESTAMP)
	private Date senddate;
	
	/** 附件 */
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
	@JoinTable(name="mail_attachment")
	private Set<Attachment> attachment = new HashSet<Attachment>();

	public String getMailid() {
		return mailid;
	}

	public void setMailid(String mailid) {
		this.mailid = mailid;
	}

	public String getSubjec() {
		return subjec;
	}

	public void setSubjec(String subjec) {
		this.subjec = subjec;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getSendto() {
		return sendto;
	}

	public void setSendto(String sendto) {
		this.sendto = sendto;
	}

	public String getCperson() {
		return cperson;
	}

	public void setCperson(String cperson) {
		this.cperson = cperson;
	}

	public String getBcperson() {
		return bcperson;
	}

	public void setBcperson(String bcperson) {
		this.bcperson = bcperson;
	}

	public Integer isMimemessage() {
		return mimemessage;
	}

	public void setMimemessage(Integer mimemessage) {
		this.mimemessage = mimemessage;
	}

	public Integer isSentok() {
		return sentok;
	}

	public void setSentok(Integer sentok) {
		this.sentok = sentok;
	}

	public String getErrormessage() {
		return errormessage;
	}

	public void setErrormessage(String errormessage) {
		this.errormessage = errormessage;
	}

	public Date getSenddate() {
		return senddate;
	}

	public void setSenddate(Date senddate) {
		this.senddate = senddate;
	}

	public Set<Attachment> getAttachment() {
		return attachment;
	}

	public void setAttachment(Set<Attachment> attachment) {
		this.attachment = attachment;
	}
	
}
